package kosta.model.board;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class NewsBoardDaoImpl implements NewsBoardDao{
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	public List<BoardVO> getListBoard(String pageNo) {
		return sqlSessionTemplate.selectList("newsboard.getListBoard",pageNo);
	}
	public BoardVO getViewBoard(int no) {
		return sqlSessionTemplate.selectOne("newsboard.getViewBoard",no);
	}
	public void newsWrite(BoardVO vo) {
		sqlSessionTemplate.insert("newsboard.writeBoard",vo);
		
	}
	public void newsUpdate(BoardVO vo) {
		sqlSessionTemplate.update("newsboard.updateBoard",vo);
		
	}
	public void newsDelete(int no) {
		sqlSessionTemplate.delete("newsboard.deleteBoard",no);
		
	}
	@Override
	public void updateCount(int no) {
		sqlSessionTemplate.update("newsboard.updateCount",no);
		
	}
	@Override
	public int totalContent() {
		return sqlSessionTemplate.selectOne("newsboard.totalContent");
	}
	@Override
	public List<BoardVO> newsSearchTitle(HashMap map) {
		return sqlSessionTemplate.selectList("newsboard.searchTitle",map);
	}
	@Override
	public int totalContentByTitle(String text) {
		return sqlSessionTemplate.selectOne("newsboard.totalContentByTitle",text);
	}
	@Override
	public BoardVO getViewBoard() throws SQLException {
		return sqlSessionTemplate.selectOne("newsboard.getRandViewBoard");
	}


}
